package com.romaremez.testuser.src.userdata;

import com.romaremez.testuser.src.testsystem.QuestionStep;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class UserSession implements Serializable  {
    private List<QuestionStep> questionSteps;
    private boolean finished;

    public UserSession() {
        finished = false;
        questionSteps = new ArrayList<>();
    }

    public boolean isFinished() {
        return finished;
    }

    public void finishSession() {
        finished = true;
    }

    public void addQuestionStep(QuestionStep questionStep) {
        questionSteps.add(questionStep);
    }

    public QuestionStep getQuestionStep(int index) {
        return questionSteps.get(index);
    }

    public void deleteQuestionStep(QuestionStep questionStep) {
        questionSteps.remove(questionStep);
    }

    public boolean contains(QuestionStep questionStep) {
        return  questionSteps.contains(questionStep);
    }

    public int size() {
        return questionSteps.size();
    }

    public int getPoints() {
        int result =0;
        for (QuestionStep questionStep : questionSteps) {
            result += questionStep.getPoints();
        }
        return result;
    }
}
